Skip to content

Fix mirrored Android background masks after a flipped readback - #242

Closed
sierpinskid wants to merge 1 commit into
mainfrom
bugfix/UNI-270-android-mask-readback-layout
Closed

sierpinskid wants to merge 1 commit into
mainfrom
bugfix/UNI-270-android-mask-readback-layout

Conversation

@sierpinskid

Copy link
Copy Markdown
Member

Summary

  • Fixes UNI-270. On Android, a portrait background-filter mask is mirrored because the Y flip applied after AsyncGPUReadback is not undone before upload.
  • PersonMaskOrientation.ToReadbackLayout maps the mask back to the readback layout. GLES is still not flipped. Vulkan and Metal still flip once, and that flip is now reversed before SetPixelData.
  • Debug latency logs in the segmenter stay behind STREAM_DEBUG_ENABLED && STREAM_LOG_BG_FILTER. No sample, package, or native binary changes.

Test plan

  • Unity 2021.3.21f1 EditMode: PersonMaskOrientationTests 14 passed, including the new readback round-trip at 0/90/180/270 with and without the Y flip. AndroidMlKitPersonSegmenterTests 1 passed.
  • CI on 2021.3.36f1 and 6000.2.12f1.
  • Android device blur is not claimed by these Editor tests.

Made with Cursor

Undo the post-readback Y flip before upload so a rotated portrait mask lines up with the camera.

Co-authored-by: Cursor <cursoragent@cursor.com>
@getstream-metis

Copy link
Copy Markdown

👋 Hi Daniel, want a second pair of eyes on this?

I'm Jeffery, Stream's review agent. I look for bugs, regressions, missing tests and slow paths, and I only post findings I've checked against the code.

  • Review this PR

Or comment /jeffery review. I'll stay quiet unless you ask.

@sierpinskid

Copy link
Copy Markdown
Member Author

Superseded without merging.

This patch undoes a Y flip on the async GPU readback path. On OpenGLES that path is not flipped, and the segmenter still reuses one ML Kit bitmap. That reuse froze STREAM_MODE on the first person, which is the blur failure reproduced on device.

The replacement copies the camera with ReadPixels, flips the bottom-up buffer before rotation, and submits a new bitmap per frame. The cutout followed a live head on OpenGLES. A new PR will carry that fix. This branch stays unmerged.

@sierpinskid

Copy link
Copy Markdown
Member Author

Replacement: #246 (UNI-276).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant